package com.olive.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.ClientDetailsService;
import org.springframework.security.oauth2.provider.ClientRegistrationException;
import org.springframework.stereotype.Service;

import com.olive.dto.OAuth2ClientDto;
import com.olive.entity.OAuth2Client;
import com.olive.mapper.OAuth2ClientMapper;

@Service
public class ClientDetailsServiceImpl implements ClientDetailsService {

	@Autowired
	private OAuth2ClientMapper oAuth2ClientMapper;

	@Override
	public ClientDetails loadClientByClientId(String clientId) throws ClientRegistrationException {
		OAuth2Client oAuth2Client = oAuth2ClientMapper.queryByClientId(clientId);
		return new OAuth2ClientDto(oAuth2Client);
	}
}

